package mybatisTest.reflect;

import mybatisTest.test.some.Dog;
import org.apache.ibatis.reflection.DefaultReflectorFactory;
import org.apache.ibatis.reflection.MetaClass;
import org.apache.ibatis.reflection.Reflector;
import org.junit.Test;

import java.util.Arrays;

public class MetaClassTest {
    @Test
    public void test1(){
        Dog2[] ds={new Dog2(),new Dog2(),new Dog2()};
        String expr="dog[4].name.Dog";
        Reflector reflector=new Reflector(Dog.class);

        MetaClass metaClass=MetaClass.forClass(Dog.class,new DefaultReflectorFactory());

        Class<?> getC = metaClass.getGetterType("age"); //Integer
        String[] getterNames = metaClass.getGetterNames();    //name age sex
        System.out.println(Arrays.toString(getterNames));
    }
    @Test
    public void test2(){
        MetaClass metaClass=MetaClass.forClass(Ren.class,new DefaultReflectorFactory());

        String property = metaClass.findProperty("orders[3].price");
        System.out.println(property);
    }
}
class Dog2{
    public Dog adog;
    public int name;
}
